package com.study.demoservice.controller;

import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("header")
public class HeaderController {

    @RequestMapping(path = "h1", method = RequestMethod.GET)
    public String hello(@RequestHeader("headerName") String name) {
        return name;
    }

    @RequestMapping(path = "h2", method = RequestMethod.GET)
    public String hello2(@RequestHeader() Map name) {
        return name.toString();
    }

    /**
     * 可以接收多个 Value 的 Map
     * @param name
     * @return
     */
    @RequestMapping(path = "h3", method = RequestMethod.GET)
    public String hello3(@RequestHeader() MultiValueMap name) {
        return name.toString();
    }
}
